IdeaBlade DevForce 2010 Help Reference
AddAction(PropertyInterceptorAction<TArgs>) Method
See Also  Example Send Feedback
IdeaBlade.Core Assembly > IdeaBlade.Core Namespace > PropertyInterceptor<TInstance,TValue,TArgs> Class > AddAction Method : AddAction(PropertyInterceptorAction<TArgs>) Method



interceptorAction
Adds an action to the interceptor.

Syntax

Visual Basic (Declaration) 
Public Overloads Sub AddAction( _
   ByVal interceptorAction As PropertyInterceptorAction(Of TArgs) _
) 
Visual Basic (Usage)Copy Code
Dim instance As PropertyInterceptor(Of TInstance,TValue,TArgs)
Dim interceptorAction As PropertyInterceptorAction(Of TArgs)
 
instance.AddAction(interceptorAction)
C# 
public void AddAction( 
   PropertyInterceptorAction<TArgs> interceptorAction
)
C++/CLI 
public:
void AddAction( 
   PropertyInterceptorAction<TArgs^>^ interceptorAction
) 

Parameters

interceptorAction

Example

C#Copy Code
public void Sample() {

  // Add a BeforeGet action on Employe.Address  
  var piAction = new PropertyInterceptorAction<DataEntityPropertyGetInterceptorArgs<Employee, String>>(
            typeof(Employee),
            Employee.EntityPropertyNames.Address,
            PropertyInterceptorMode.BeforeGet,
            TraceGetter);
  PropertyInterceptorManager.CurrentInstance.AddAction(piAction);

  // Add a BeforeSet action on Employee.Country
  var piAction2 = new PropertyInterceptorAction<DataEntityPropertySetInterceptorArgs<Employee, String>>(
      typeof(Employee),
      Employee.EntityPropertyNames.Country,
      PropertyInterceptorMode.BeforeSet,
      TraceSetter);
  PropertyInterceptorManager.CurrentInstance.AddAction(piAction2);

  // Get/set a few properties
  DomainModelEntityManager mgr = DomainModelEntityManager.DefaultManager;
  Employee e = mgr.Employees.First();
  string addy = e.Address;
  e.Country = "UK";
}
    
public static void TraceGetter(DataEntityPropertyGetInterceptorArgs<Employee, String>> args) {
  Console.WriteLine("getter called for " + args.DataEntityProperty.Name);
}

public static void TraceSetter(DataEntityPropertySetInterceptorArgs<Employee, String>> args) {
  Console.WriteLine("setter called for " + args.DataEntityProperty.Name);
}

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

© 2013 All Rights Reserved.